package com.aa;

import java.util.ArrayList;
import java.util.HashMap;

import com.aa.setting.BangDingActivity;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.LinearLayout;
import android.widget.SimpleAdapter;
import android.widget.TextView;
import android.widget.Toast;

public class MoreActivity extends Activity {

	private CornerListView mCornerListView1;
	private CornerListView mCornerListView2;
	private CornerListView mCornerListView3;
	private CornerListView mCornerListView4;
	private TextView mTitleView;
	private TextView mlyView;
	private LinearLayout lyButton;
	int[] menu_image_array1 = { R.drawable.more_new_info, R.drawable.more_make_moeny };
	int[] menu_image_array2 = { R.drawable.more_balance_inquiry, R.drawable.more_bindcall, R.drawable.more_calldisp };
	int[] menu_image_array3 = { R.drawable.more_hotline };
	int[] menu_image_array4 = { R.drawable.more_tariff, R.drawable.more_upgrade, R.drawable.more_official_website, R.drawable.more_about, R.drawable.more_help };
	int[] menu_image_array4_1 = { R.drawable.more_tariff, R.drawable.more_upgrade, R.drawable.more_about, R.drawable.more_help };
	int[] menu_name_array1 = { R.string.more_title_1, R.string.more_title_2 };
	int[] menu_name_array2 = { R.string.more_title_3, R.string.more_title_6, R.string.more_title_15 };
	int[] menu_name_array3 = { R.string.more_hjsz };
	int[] menu_name_array4 = { R.string.more_title_8, R.string.more_title_11, R.string.more_title_10, R.string.more_title_13, R.string.more_title_14 };
	int[] menu_name_array4_1 = { R.string.more_title_8, R.string.more_title_11, R.string.more_title_13, R.string.more_title_14 };
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.more);
		initView();
		createListView1();
		createListView2();
		createListView3();
		//createListView4();
		createListView4_1();
	}
	
	private void initView(){
	    mTitleView = ((TextView)findViewById(R.id.index_center_tx));
	    mTitleView.setVisibility(View.VISIBLE);
	    mTitleView.setText(R.string.bar_more);
	    mlyView = ((TextView)findViewById(R.id.index_btn_tx));
	    mlyView.setVisibility(View.VISIBLE);
	    mlyView.setText(R.string.index_call_kf);
	    lyButton = ((LinearLayout)findViewById(R.id.index_btn_ly));
	    lyButton.setVisibility(View.VISIBLE);
	    lyButton.setOnClickListener(new View.OnClickListener()
	    {
	      public void onClick(View paramAnonymousView)
	      {
	       // Common.iTempUseSystemTel = true;
	        Uri _Uri = Uri.parse("tel:" + Common.serviceTel);
	        startActivity(new Intent("android.intent.action.CALL", _Uri));
	      }
	    });
	}
	
	private void createListView1()
	  {
		mCornerListView1 = ((CornerListView)findViewById(R.id.more_list1));
		mCornerListView1.setAdapter(getMenuAdapter(menu_name_array1, menu_image_array1));
		mCornerListView1.setOnItemClickListener(new AdapterView.OnItemClickListener(){
			
	      public void onItemClick(AdapterView<?> AdapterView, View v, int position, long paramAnonymousLong)
	      {
	        if (position == 0)
	        {
//	          Intent _Intent = new Intent();
//	          _Intent.setClass(MoreActivity.this, NewFavourableActivity.class);
//	          MoreActivity.this.startActivity(_Intent);
	        	return;
	        }
	       if (position == 1) {
//	    	   Intent _Intent = new Intent();
//	    	   _Intent.setClass(MoreActivity.this, CommendActivity.class);
//		        MoreActivity.this.startActivity(_Intent);
	    	   return;
	       }
	       
	      }
	    });
	  } 
	
	private void createListView3()
	  {
	    mCornerListView3 = ((CornerListView)findViewById(R.id.more_list3));
	    mCornerListView3.setAdapter(getMenuAdapter(menu_name_array3, menu_image_array3));
	    mCornerListView3.setOnItemClickListener(new AdapterView.OnItemClickListener()
	    {
	      public void onItemClick(AdapterView<?> AdapterView, View v, int position, long paramAnonymousLong)
	      {
//	        Intent localIntent;
//	        if (position == 0)
//	        {
//	          localIntent = new Intent();
//	          if (Common.iShowGroupCall != 1)
//	            break label42;
//	          localIntent.setClass(MoreActivity.this, CallSettingActivity.class);
//	        }
//	        while (true)
//	        {
//	          MoreActivity.this.startActivity(localIntent);
//	          return;
//	          label42: localIntent.setClass(MoreActivity.this, CallSettingActivity2.class);
//	        }
	      }
	    });
	  }
	private void createListView2(){
		
		mCornerListView2 = ((CornerListView)findViewById(R.id.more_list2));
		mCornerListView2.setAdapter(getMenuAdapter(menu_name_array2, menu_image_array2));
		mCornerListView2.setOnItemClickListener(new AdapterView.OnItemClickListener(){
		     
			public void onItemClick(AdapterView<?> AdapterView, View v, int position, long paramAnonymousLong)
		    {
		        if (position == 0)
		        {
		          		        	  
		           // Common.InitSettingsFile(MoreActivity.this.getApplicationContext(), 0);
		          if (Common.iLogin != 1)
		          {
		              String str = getString(R.string.app_tip_bangding);
		              Toast.makeText(MoreActivity.this, str, 3000).show();
		              return;
		          }
		          
		          	Intent _Intent = new Intent();
		          	_Intent.setClass(MoreActivity.this, BalanceActivity.class);
		          	startActivity(_Intent);
		          	return;
		          }
		       
		        		      
		        if (position == 1)
		        {		        	
		        	
		            Intent _Intent = new Intent();
		            _Intent.setClass(MoreActivity.this, BangDingActivity.class);
		            startActivity(_Intent);
		            return;
		        }
		        if (position == 2) {
//		        	Intent _Intent = new Intent();
//		        	_Intent.setClass(MoreActivity.this, AccountManagerActivity.class);
//			        MoreActivity.this.startActivity(_Intent);
		        	return;
				}		      		        
		      }
		    });
	}
	 private void createListView4(){
		 
	    mCornerListView4 = ((CornerListView)findViewById(R.id.more_list5));
	    mCornerListView4.setAdapter(getMenuAdapter(this.menu_name_array4, this.menu_image_array4));
	    mCornerListView4.setOnItemClickListener(new AdapterView.OnItemClickListener(){
	    	
	      public void onItemClick(AdapterView<?> AdapterView, View v, int position, long paramAnonymousLong)
	      {
	        if (position == 0)
	        {
//	          Intent localIntent1 = new Intent();
//	          localIntent1.setClass(MoreActivity.this, ChargeIntroActivity.class);
//	          MoreActivity.this.startActivity(localIntent1);
	        	return;
	        }
	       
	        if (position == 1)
	        {
	            //submitUpdate();
	            return;
	        }
	        if (position == 2)
	        {
//	            Intent localIntent2 = new Intent("android.intent.action.VIEW", Uri.parse(MoreActivity.this.getApplicationContext().getString(2131361866)));
//	            MoreActivity.this.startActivity(localIntent2);
	            return;
	         }
	        if (position == 3)
	        {
//	            Intent localIntent3 = new Intent();
//	            localIntent3.setClass(MoreActivity.this, AboutActivity.class);
//	            MoreActivity.this.startActivity(localIntent3);
	            return;
	         }
	        if (position == 4) {
//	        	 Intent localIntent4 = new Intent();
//	 	        localIntent4.setClass(MoreActivity.this, HelpActivity.class);
//	 	        MoreActivity.this.startActivity(localIntent4);
	        	return;
			}
	        return;
	       
	      }
	    });
	  }

	 private void createListView4_1()
	  {
	    mCornerListView4 = ((CornerListView)findViewById(R.id.more_list5));
	    mCornerListView4.setAdapter(getMenuAdapter(menu_name_array4_1, menu_image_array4_1));
	    mCornerListView4.setOnItemClickListener(new AdapterView.OnItemClickListener()
	    {
	      public void onItemClick(AdapterView<?> AdapterView, View v, int position, long paramAnonymousLong)
	      {
	        if (position == 0)
	        {
//	          Intent localIntent1 = new Intent();
//	          localIntent1.setClass(MoreActivity.this, ChargeIntroActivity.class);
//	          MoreActivity.this.startActivity(localIntent1);
	        	return;
	        }
	       
	          
	          if (position == 1)
	          {
	            //MoreActivity.this.submitUpdate();
	            return;
	          }
	          if (position == 2)
	          {
//	            Intent localIntent2 = new Intent();
//	            localIntent2.setClass(MoreActivity.this, AboutActivity.class);
//	            MoreActivity.this.startActivity(localIntent2);
	            return;
	          }
	          if (position == 3) {
//	        	  Intent localIntent3 = new Intent();
//	  	        localIntent3.setClass(MoreActivity.this, HelpActivity.class);
//	  	        MoreActivity.this.startActivity(localIntent3);
	        	  return;
	          }
	       
	        
	      }
	    });
	  }

	private SimpleAdapter getMenuAdapter(int[] pText, int[] pImage)
	  {
	    ArrayList _ArrayList = new ArrayList();
	    for (int i = 0; ; i++)
	    {
	      if (i >= pText.length)
	        return new SimpleAdapter(this, _ArrayList, R.layout.more_list_item, new String[] { "title", "img" }, new int[] { R.id.title, R.id.img });
	      HashMap _HashMap = new HashMap();
	      _HashMap.put("title", getApplicationContext().getString(pText[i]));
	      _HashMap.put("img", Integer.valueOf(pImage[i]));
	      _ArrayList.add(_HashMap);
	    }
	  }
}
